/*******************************************************************/
/*    Copyright (c) 2008-2010 by Spatial Corp.                     */
/*    All rights reserved.                                         */
/*******************************************************************/

#if !defined(EBOM_XML_PARSER_H_)
#define EBOM_XML_PARSER_H_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "EBomTreeNode.h"

#include <vector>

#ifdef XERCES_YES

#include <xercesc/dom/DOM.hpp>
#include <xercesc/dom/DOMNode.hpp>



#define SIZE 256

using xercesc::DOMNode;
using namespace std;

class EBomXmlParser
{
public:
			EBomXmlParser();
	virtual	~EBomXmlParser();

	void	ParserXMLFile( const char* xmlFileName, const char* locale = "america" );
	void	ParserXMLFile( const TCHAR* xmlFileName, const char* locale = "america" );

	void	DeleteAsmTreeNode( EBomTreeNode*& pAsmNode );

	EBomTreeNode* GetEBomTreeNode()
	{
		return m_TreeNode;
	};
	const TCHAR*	GetRootName();

private:
	void			GetNodeAttributes( DOMNode* pNode, int& numOfChild, XMLCh* nodeName, XMLCh* refLinkId, double*& positionMatrix );
	void			BuildAssemblyTree( DOMNode* pNode, EBomTreeNode*& pAsmNode, int nDepth );

	//wumin 2004.12.30
	bool			ModifyXMLEncoding( const TCHAR* xmlFileName, const char* locale = "america" );


private:
	struct EBomDocument
	{
		TCHAR			docName[SIZE];
		TCHAR			docType[SIZE];
		TCHAR			docIdentifier[SIZE*4];
		TCHAR			docFilePath[SIZE*4];
	};

	std::vector<EBomDocument>	m_DocList;

	TCHAR			m_rootName[SIZE];
	EBomTreeNode*	m_TreeNode;
};

#endif // ifdef XERCES_YES
#endif // !defined(EBOM_XML_PARSER_H_)